package com.yl.auth.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.entity.Hugong;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yl.auth.entity.HugongBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 王帅洋
 * @datetime 2023/6/19 9:41
 * @description 类对象
 */
@Mapper
public interface HugongMapper extends BaseMapper<HugongBean> {


    IPage<HugongBean> findAll(Page<HugongBean> page1, @Param("hugongBean") HugongBean hugongBean);
    @Select(" SELECT h.*,GROUP_CONCAT(o.name)oname,COUNT(o.`name`) laorencount from hugong h\n" +
            "        LEFT JOIN hugong_laoren z on h.id = z.hid\n" +
            "        LEFT JOIN laoren o on z.lid = o.id\n" +
            "where h.id=#{id}\n" +
            "GROUP BY h.id")
    HugongBean selectByIdHugong(Integer id);
    @Insert("insert into hugong(touxiang,hname,phone,gangwei)\n" +
            "values(#{touxiang},#{hname},#{phone},#{gangwei})")
    void gethugong(Hugong hugong);
}
